class HelloWorld {
	public void sayHello(String name) {
		println "saying Hello to $name"
		println "Hello " + name + "!"
	}
}
class HelloWorldInterceptor implements Interceptor {
	Object beforeInvoke(Object object, String methodName, Object[] arguments) {
		println "before " + methodName
		null
	}
	boolean doInvoke() {
		true
	}
	Object afterInvoke(Object object, String methodName, Object[] arguments, Object result) {
		println "after " + methodName
		result
	}
}

def proxy = ProxyMetaClass.getInstance(HelloWorld)
proxy.interceptor = new HelloWorldInterceptor()
proxy.use {
	def helloworld = new HelloWorld()
	helloworld.sayHello("kongxx")
}
